//
//  ZCfollowModelContent.m
//
//  Created by   on 16/1/8
//  Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//

#import "ZCfollowModelContent.h"


NSString *const kZCfollowModelContentFinish = @"finish";
NSString *const kZCfollowModelContentId = @"id";
NSString *const kZCfollowModelContentMid = @"mid";
NSString *const kZCfollowModelContentThumb = @"thumb";
NSString *const kZCfollowModelContentCtype = @"ctype";
NSString *const kZCfollowModelContentState = @"state";
NSString *const kZCfollowModelContentPackagename = @"packagename";
NSString *const kZCfollowModelContentLocation = @"location";
NSString *const kZCfollowModelContentCtime = @"ctime";
NSString *const kZCfollowModelContentPjname = @"pjname";
NSString *const kZCfollowModelContentEmoney = @"emoney";
NSString *const kZCfollowModelContentResult = @"result";
NSString *const kZCfollowModelContentForId = @"for_id";
NSString *const kZCfollowModelContentRate = @"rate";
NSString *const kZCfollowModelContentShowMarkIcon = @"show_mark_icon";

NSString *const kZCfollowModelContentTestingdate = @"testing_date";
NSString *const kZCfollowModelContentBatch = @"batch";

NSString *const kZCfollowModelContentTesting_result  = @"testing_result";

@interface ZCfollowModelContent ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation ZCfollowModelContent

@synthesize batch = _batch;
@synthesize testingdate = _testingdate;

@synthesize finish = _finish;
@synthesize contentIdentifier = _contentIdentifier;
@synthesize mid = _mid;
@synthesize thumb = _thumb;
@synthesize ctype = _ctype;
@synthesize state = _state;
@synthesize packagename = _packagename;
@synthesize location = _location;
@synthesize ctime = _ctime;
@synthesize pjname = _pjname;
@synthesize emoney = _emoney;
@synthesize result = _result;
@synthesize forId = _forId;
@synthesize rate = _rate;
@synthesize showMarkIcon = _showMarkIcon;
@synthesize testing_result = _testing_result;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.finish = [self objectOrNilForKey:kZCfollowModelContentFinish fromDictionary:dict];
            self.contentIdentifier = [self objectOrNilForKey:kZCfollowModelContentId fromDictionary:dict];
            self.mid = [self objectOrNilForKey:kZCfollowModelContentMid fromDictionary:dict];
            self.thumb = [self objectOrNilForKey:kZCfollowModelContentThumb fromDictionary:dict];
            self.ctype = [self objectOrNilForKey:kZCfollowModelContentCtype fromDictionary:dict];
            self.state = [self objectOrNilForKey:kZCfollowModelContentState fromDictionary:dict];
            self.packagename = [self objectOrNilForKey:kZCfollowModelContentPackagename fromDictionary:dict];
            self.location = [self objectOrNilForKey:kZCfollowModelContentLocation fromDictionary:dict];
            self.ctime = [self objectOrNilForKey:kZCfollowModelContentCtime fromDictionary:dict];
            self.pjname = [self objectOrNilForKey:kZCfollowModelContentPjname fromDictionary:dict];
            self.emoney = [self objectOrNilForKey:kZCfollowModelContentEmoney fromDictionary:dict];
            self.result = [self objectOrNilForKey:kZCfollowModelContentResult fromDictionary:dict];
            self.forId = [self objectOrNilForKey:kZCfollowModelContentForId fromDictionary:dict];
            self.rate = [[self objectOrNilForKey:kZCfollowModelContentRate fromDictionary:dict] doubleValue];
            self.showMarkIcon = [self objectOrNilForKey:kZCfollowModelContentShowMarkIcon fromDictionary:dict];
        self.testingdate = [self objectOrNilForKey:kZCfollowModelContentTestingdate fromDictionary:dict];
        self.batch = [self objectOrNilForKey:kZCfollowModelContentBatch fromDictionary:dict];
        self.testing_result = [self objectOrNilForKey:kZCfollowModelContentTesting_result fromDictionary:dict];
    }
    return self;
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.finish forKey:kZCfollowModelContentFinish];
    [mutableDict setValue:self.contentIdentifier forKey:kZCfollowModelContentId];
    [mutableDict setValue:self.mid forKey:kZCfollowModelContentMid];
    [mutableDict setValue:self.thumb forKey:kZCfollowModelContentThumb];
    [mutableDict setValue:self.ctype forKey:kZCfollowModelContentCtype];
    [mutableDict setValue:self.state forKey:kZCfollowModelContentState];
    [mutableDict setValue:self.packagename forKey:kZCfollowModelContentPackagename];
    [mutableDict setValue:self.location forKey:kZCfollowModelContentLocation];
    [mutableDict setValue:self.ctime forKey:kZCfollowModelContentCtime];
    [mutableDict setValue:self.pjname forKey:kZCfollowModelContentPjname];
    [mutableDict setValue:self.emoney forKey:kZCfollowModelContentEmoney];
    [mutableDict setValue:self.result forKey:kZCfollowModelContentResult];
    [mutableDict setValue:self.forId forKey:kZCfollowModelContentForId];
    [mutableDict setValue:[NSNumber numberWithDouble:self.rate] forKey:kZCfollowModelContentRate];
    [mutableDict setValue:self.showMarkIcon forKey:kZCfollowModelContentShowMarkIcon];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.finish = [aDecoder decodeObjectForKey:kZCfollowModelContentFinish];
    self.contentIdentifier = [aDecoder decodeObjectForKey:kZCfollowModelContentId];
    self.mid = [aDecoder decodeObjectForKey:kZCfollowModelContentMid];
    self.thumb = [aDecoder decodeObjectForKey:kZCfollowModelContentThumb];
    self.ctype = [aDecoder decodeObjectForKey:kZCfollowModelContentCtype];
    self.state = [aDecoder decodeObjectForKey:kZCfollowModelContentState];
    self.packagename = [aDecoder decodeObjectForKey:kZCfollowModelContentPackagename];
    self.location = [aDecoder decodeObjectForKey:kZCfollowModelContentLocation];
    self.ctime = [aDecoder decodeObjectForKey:kZCfollowModelContentCtime];
    self.pjname = [aDecoder decodeObjectForKey:kZCfollowModelContentPjname];
    self.emoney = [aDecoder decodeObjectForKey:kZCfollowModelContentEmoney];
    self.result = [aDecoder decodeObjectForKey:kZCfollowModelContentResult];
    self.forId = [aDecoder decodeObjectForKey:kZCfollowModelContentForId];
    self.rate = [aDecoder decodeDoubleForKey:kZCfollowModelContentRate];
    self.showMarkIcon = [aDecoder decodeObjectForKey:kZCfollowModelContentShowMarkIcon];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_finish forKey:kZCfollowModelContentFinish];
    [aCoder encodeObject:_contentIdentifier forKey:kZCfollowModelContentId];
    [aCoder encodeObject:_mid forKey:kZCfollowModelContentMid];
    [aCoder encodeObject:_thumb forKey:kZCfollowModelContentThumb];
    [aCoder encodeObject:_ctype forKey:kZCfollowModelContentCtype];
    [aCoder encodeObject:_state forKey:kZCfollowModelContentState];
    [aCoder encodeObject:_packagename forKey:kZCfollowModelContentPackagename];
    [aCoder encodeObject:_location forKey:kZCfollowModelContentLocation];
    [aCoder encodeObject:_ctime forKey:kZCfollowModelContentCtime];
    [aCoder encodeObject:_pjname forKey:kZCfollowModelContentPjname];
    [aCoder encodeObject:_emoney forKey:kZCfollowModelContentEmoney];
    [aCoder encodeObject:_result forKey:kZCfollowModelContentResult];
    [aCoder encodeObject:_forId forKey:kZCfollowModelContentForId];
    [aCoder encodeDouble:_rate forKey:kZCfollowModelContentRate];
    [aCoder encodeObject:_showMarkIcon forKey:kZCfollowModelContentShowMarkIcon];
}

- (id)copyWithZone:(NSZone *)zone
{
    ZCfollowModelContent *copy = [[ZCfollowModelContent alloc] init];
    
    if (copy) {

        copy.finish = [self.finish copyWithZone:zone];
        copy.contentIdentifier = [self.contentIdentifier copyWithZone:zone];
        copy.mid = [self.mid copyWithZone:zone];
        copy.thumb = [self.thumb copyWithZone:zone];
        copy.ctype = [self.ctype copyWithZone:zone];
        copy.state = [self.state copyWithZone:zone];
        copy.packagename = [self.packagename copyWithZone:zone];
        copy.location = [self.location copyWithZone:zone];
        copy.ctime = [self.ctime copyWithZone:zone];
        copy.pjname = [self.pjname copyWithZone:zone];
        copy.emoney = [self.emoney copyWithZone:zone];
        copy.result = [self.result copyWithZone:zone];
        copy.forId = [self.forId copyWithZone:zone];
        copy.rate = self.rate;
        copy.showMarkIcon = [self.showMarkIcon copyWithZone:zone];
    }
    
    return copy;
}


@end
